package com.lizhenhua.stockdel.service.impl;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.lizhenhua.stockdel.mapper.StockDelMapper;
import com.lizhenhua.stockdel.service.StockDelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class StockDelServiceImpl implements StockDelService {
    @Autowired
    private StockDelMapper stockDelMapper;

    @Override
    @Transactional    // 和下面Lcn 一起用
    @LcnTransaction  // lcn模式 分布式事务注解
    public int delShopCart(String cids) {
        int j = 1;

        // 把字符串分割为数组
        String[] split = cids.split(",");

        for (String s : split
        ) {
            int i1 = Integer.parseInt(s);
            int i = stockDelMapper.deleteByPrimaryKey(i1);
            j *= i;
        }


        return j;
    }


}
